<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #box {
        position: absolute;
        width: 100px;
        height: 100px;
        background-color: #ccc;
      }
    </style>
  </head>
  <body>
    <div id="box">233</div>

    <script>
      var boxEle = document.getElementById('box');
      var cssStyle = 
      boxEle.addEventListener('mousedown', function () {
        console.log('hhh');
        document.addEventListener('mousemove', fn);
        console.log('move');
        //   var X = event.clientX;
        //   var Y = event.clientY;
        //   boxEle.style.top = X + 'px';
        //   boxEle.style.left = Y + 'px';

        function fn(event) {
          var X = event.clientX;
          var Y = event.clientY;
          boxEle.style.top = Y + 'px';
          boxEle.style.left = X + 'px';
        }
        boxEle.addEventListener('mouseup', function () {
          console.log('up');
          document.removeEventListener('mousemove', fn);
        });
      });
    </script>
  </body>
</html>
